<template>
  <div class="goodsListItem" @click="goodItemClick">
    <img :src="showImg" alt="" class="goodsImg" />

    <div class="goods-info">
      <p>{{ goodsItem.title }}</p>
      <span class="price">{{ goodsItem.price }}</span>
      <span class="collect">关注:{{ goodsItem.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "goodsListItem",
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  computed: {
    showImg() {
      return this.goodsItem.image || this.goodsItem.show.img;
    }
  },
  methods: {
    // 跳转到详情页
    goodItemClick() {
      // console.log('跳转到详情页');
      // console.log(this.goodsItem.iid);
      this.$router.push("/detail/" + this.goodsItem.iid);
    }
  }
};
</script>

<style scoped>
.goodsListItem {
  width: 48%;
  position: relative;
  padding-bottom: 40px;
  /* overflow: hidden; */
}

.goodsImg {
  width: 100%;
  border-radius: 5px;
}
.goods-info {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  font-size: 12px;
  overflow: hidden;
  text-align: center;
}
.goods-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: bottom 3px;
}
.goods-info .price {
  color: pink;
  margin-right: 20px;
}
.goods-info .collect {
  position: relative;
  color: red;
}
</style>
